package com.foreknow.tijian.service.Impl;

import com.foreknow.tijian.dao.BusinessDao;
import com.foreknow.tijian.dao.Impl.BusinessDaoImpl;
import com.foreknow.tijian.po.Business;
import com.foreknow.tijian.service.BusinessService;
import com.foreknow.tijian.util.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

public class BusinessServiceImpl implements BusinessService {
    Connection conn= DBUtil.getConnection();
    PreparedStatement pst;
    @Override
    public List<Business> listBusinessByOrderTypeId(int orderTypeId) throws SQLException {
        BusinessDao businessDao = new BusinessDaoImpl();
        List<Business> list=null;
        try{
            //调用Dao层的方法
            list=businessDao.listBusinessByOrderTypeId(orderTypeId);
        }
        catch(Exception e){
        }
        finally {
            //关闭资源
            DBUtil.close(pst);
        }
        return list;
    }

    @Override
    public Business getBusinessById(int id) throws SQLException {
        BusinessDao businessDao = new BusinessDaoImpl();
        Business result=new Business();
        try{
            //调用Dao层的方法
            result=businessDao.getBusinessById(id);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        finally {
            //关闭资源
            DBUtil.close(pst);
        }
        return result;
    }
}
